#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    int maxi, mini;
    ll ans = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            a[i] = -1;
            cnt++;
        }
    }
    while (cnt != n) {
        maxi = -1, mini = -1;
        for (int i = 0; i < n; i++) {
            if (a[i] == -1) continue;
            if (maxi == -1 || a[i] >= a[maxi]) maxi = i;
            if (mini == -1 || a[i] < a[mini]) mini = i;
        }
        ans ++;
        a[maxi] -= a[mini];
        if (a[maxi] == 0) {
            cnt++;
            a[maxi] = -1;
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}